package vista;

import java.awt.BorderLayout;
import java.sql.SQLException;

import javabean.JPanelImagen;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import javax.swing.WindowConstants;

import controlador.ControladorNivel;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
@SuppressWarnings("serial")
public class VistaNivel extends javax.swing.JFrame {
	
	JPanelImagen panelFondo;
	private JComboBox cmbUsuario;
	private JButton btnJugar;
	private JComboBox cmbNivel;
	private JTextField txtUsuario;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	
	public VistaNivel() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			
			
			panelFondo = new JPanelImagen();
			getContentPane().add(panelFondo, BorderLayout.CENTER);
			panelFondo.setRutaImagen("/imagenes/fondo.jpg");
			panelFondo.setPreferredSize(new java.awt.Dimension(384, 262));
			panelFondo.setBackground(new java.awt.Color(255,255,255));
			{
					
				cmbUsuario = new JComboBox();
				panelFondo.add(cmbUsuario);
				cmbUsuario.setBounds(63, 57, 174, 23);
			}
			{
				txtUsuario = new JTextField();
				panelFondo.add(txtUsuario);
				txtUsuario.setBounds(63, 92, 174, 23);
			}
			{
				ComboBoxModel cmbNivelModel = 
					new DefaultComboBoxModel(
							new String[] { "Nivel 1", "Nivel 2", "Nivel 3" });
				cmbNivel = new JComboBox();
				panelFondo.add(cmbNivel);
				cmbNivel.setModel(cmbNivelModel);
				cmbNivel.setBounds(63, 127, 174, 23);
			}
			{
				btnJugar = new JButton();
				panelFondo.add(btnJugar);
				btnJugar.setText("Empezar");
				btnJugar.setBounds(198, 178, 150, 50);
			}
			
			registrarControlador();
			pack();
			setSize(400, 300);
			this.setVisible(true);
			this.setLocationRelativeTo(null);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public JPanelImagen getPanelFondo() {
		return panelFondo;
	}

	public void setPanelFondo(JPanelImagen panelFondo) {
		this.panelFondo = panelFondo;
	}

	public JComboBox getCmbUsuario() {
		return cmbUsuario;
	}

	public void setCmbUsuario(JComboBox cmbUsuario) {
		this.cmbUsuario = cmbUsuario;
		//cmbUsuario.addActionListener(%0.%1.controlador);
	}

	public JButton getBtnJugar() {
		return btnJugar;
	}

	public void setBtnJugar(JButton btnJugar) {
		this.btnJugar = btnJugar;
	}

	public JComboBox getCmbNivel() {
		return cmbNivel;
	}

	public void setCmbNivel(JComboBox cmbNivel) {
		this.cmbNivel = cmbNivel;
	}

	public JTextField getTxtUsuario() {
		return txtUsuario;
	}

	public void setTxtUsuario(JTextField txtUsuario) {
		this.txtUsuario = txtUsuario;
	}
	
	public void registrarControlador() throws SQLException{
		
		ControladorNivel controlador = new ControladorNivel(this);
		btnJugar.addActionListener(controlador);
		cmbUsuario.addActionListener(controlador);
		
	}
	
	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
}

